<template>
	<view class="page">
		<scroll-view class="list" scroll-y = true>
			<view class="box" v-if="clueList.length > 0">
				<view class="item" v-for="item in clueList" :key="item.create_time">
					<img :src="item.style_cover" alt="">
					<view class="info">
						<view class="title">{{item.style_name}}</view>
						<view class="info-item">购车城市：{{item.city}}</view>
						<view class="info-item"v-if="item.dea_name">经销商：{{item.dea_name}}</view>
						<view class="info-item">创建时间：{{item.create_time}}</view>
					</view>
				</view>
			</view>
			
			<view class="nothing" v-if="clueList.length == 0">
				<img src="../../static/image/nothing.png" alt="" mode="widthFix">
				<view class="text">暂无内容</view>
			</view>
			
		</scroll-view>
		
		
	</view>
</template>

<script>
	const Api = require('../../utils/api.js');
	const request = require('../../utils/request.js');
	export default {
		data() {
			return { 
				clueList: [],
				page: 1,
				isLoading: false,
				total: 0
			}
		},
		onLoad() {
			this.getClueData()
		},
		onReachBottom() {
			console.log(1)
			if (this.isLoading) return		
				
			if(this.page * 10  >= this.total) {
				console.log(333)
				uni.showToast({
					title: '到底啦～～',
					icon: 'none'
				})
				return 
			}
			this.page += 1
			this.getClueData()
		},
		methods: {
			getClueData() { 
				this.isLoading = true
				request.http(
				{
					url: Api.leave_clue_list,
					type: 'GET',
					header: {
						// // 'content-type': 'application/x-www-form-urlencoded',
						'token':uni.getStorageSync('token')
					},
					data: {
						page_size: 10,
						page: this.page
					},
					}).then(result=>{
						if(result.data.list.length > 0 ) {
							this.clueList = this.clueList.concat(result.data.list) 
						}
						this.total = result.data.total
						this.isLoading = false
						
					})
			}
		}
	}
</script>

<style lang="scss" scoped>
.page {
	width: 100%;
	padding: 21rpx;
	box-sizing: border-box;
	.item {
		width: 100%;
		display: flex;
		align-items: center;
		padding: 30rpx 15rpx;
		box-sizing: border-box;
		background: #fff;
		margin-bottom: 15rpx;
		img {
			width: 199rpx;
			height: 134rpx;
			flex-shrink: 0;
		}
		
		.info {
			display: flex;
			flex-direction: column;
			margin-left:15rpx;
			.title {
				font-weight: 500;
				color: #222526;
				font-size: 29rpx;
			}
			.info-item {
				font-weight: 400;
				color: #6E7175;
				font-size: 22rpx;
				margin-top: 10rpx;
			}
		}
	}
	.nothing {
					display: flex;
					flex-direction: column;
					align-items: center;
					margin-top: 217rpx;
					img {
						width: 271rpx;
					}
					.text {
						color: #666666;
						font-size: 29rpx;
					}
				}
}
</style>